﻿using System.Diagnostics;

namespace ApplicationMonitor
{
    internal class Program
    {
        static void Main(string[] args)
        {
            var processId = int.Parse(args[0]);
            var appPath = args[1];
            try
            {
                while (Process.GetProcessById(processId) != null)
                    Thread.Sleep(1000);
            }
            catch { }
            while (true)
            {
                try
                {
                    Process.Start(new ProcessStartInfo(appPath) { UseShellExecute = true });
                    break;
                }
                catch { }
                Thread.Sleep(1000);
            }
        }
    }
}